<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
    <title>用户与产品匹配度</title>
    <meta name="decorator" content="default"/>
    <script src="${ctxStatic}/layer/layer.js"></script>
    <script src="${ctxStatic}/js/widget/stickytableheaders/js/jquery.stickytableheaders.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function() {
            var selectId=$("#bank_select").val();
            var loanId=$("#loanId").val()||"";
            $.ajax({
                type : "POST",  //提交方式
                url : "${ctx}/sys/member/member/getLoanByBankId",//路径
                data : {"bankId":selectId},//数据，这里使用的是Json格式进行传输
                success : function(data) {//返回数据根据结果进行相应的处理
                    $("#loan_select").html("");
                    if(data){

                        for(var i = 0; i < data.length; i++){
                            var loan=data[i];
                            if(loanId==loan.id){
                                $("#loan_select").append('<option selected="selected" value="'+loan.id+'">'+loan.name+'</option>')
                            }
                            else{
                                $("#loan_select").append('<option value="'+loan.id+'" >'+loan.name+'</option>')
                            }
                        }
                    }else{
                        $("#loan_select").html("<option selected='selected'>暂无数据</option>");
                    }
                    $("#loan_select").val(loanId).trigger("change");
                }
            });
            $(".view_service_record").click(function(){
                var id=$(this).data("id");
                parent.layer.open({
                    type: 2,
                    title: '服务记录',
                    shadeClose: true,
                    shade: 0,
                    area: ['90%', '70%'],
                    content: '${ctx}/sys/member/member/seviceRecordPage?id='+id //iframe的url
                });
            });
            //查看客户信息
            $(".view-info").click(function(){
                var id=$(this).data("id");
                layer.open({
                    type: 2,
                    title:"客户信息",
                    skin: 'layui-layer-rim', //加上边框
                    offset: ['50px', '100px'],
                    area: ['900px', '500px'], //宽高
                    content: "${ctx}/sys/member/member/load/viewMemberInfoPage?id="+id
                });
            });
            $("#contentTable").stickyTableHeaders();
            $("body").on("change","#bank_select",function () {
                var selectId=$("#bank_select").val();
                var loanId=$("#loanId").val();
                $.ajax({
                    type : "POST",  //提交方式
                    url : "${ctx}/sys/member/member/getLoanByBankId",//路径
                    data : {"bankId":selectId},//数据，这里使用的是Json格式进行传输
                    success : function(data) {//返回数据根据结果进行相应的处理
                        $("#loan_select").html("");
                        if(data){
                            for(var i = 0; i < data.length; i++){
                                var loan=data[i];
//                                if(i==0){
                                if(loanId ==loan.id ){
                                    $("#loan_select").append('<option selected="selected" value="'+loan.id+'">'+loan.name+'</option>')
                                }else{
                                    $("#loan_select").append('<option value="'+loan.id+'" >'+loan.name+'</option>')
                                }
                            }
                        }else{
                            $("#loan_select").html("<option selected='selected'>暂无数据</option>");
                        }
                        $("#loan_select").val("").trigger("change");
                    }
                });
            });
        });

        function page(n,s){
            $("#pageNo").val(n);
            $("#pageSize").val(s);
            $("#searchForm").submit();
            return false;
        }

    </script>


</head>
<body>
<ul class="nav nav-tabs">
    <li class="active"><a href="${ctx}/sys/member/member/">用户匹配产品列表</a></li>
</ul>
<form:form id="searchForm" modelAttribute="loan" action="${ctx}/sys/member/member/membermate" method="post" class="breadcrumb form-search">
    <input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
    <input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
</form:form>

<sys:message content="${message}"/>
<table id="contentTable" class="table table-striped table-bordered table-condensed">
    <thead style="top: 0">

    <tr>
        <th style="width: 10%">贷款名称</th>
        <th style="width: 10%">匹配度</th>
    </tr>
    </thead>
    <tbody >
    <c:forEach items="${page.list}" var="loan">

        <tr>
            <td style="width: 10%">
                ${loan.name}
            </td>
            <td style="width: 10%">
                ${loan.membermate}
            </td>
        </tr>
    </c:forEach>
    </tbody>
</table>
<div class="pagination">${page}</div>

</body>
</html>